package com.fastloan.safe.core.util;

import com.fastloan.safe.mgt.auth.model.CmuRole;
import com.fastloan.safe.mgt.user.model.CmuUser;
import com.kawins.shiro.temp.util.ShiroKit;
import org.apache.shiro.session.Session;

/**
 * @author rankai
 *         createTime 2017-10-2017/10/19 16:18
 */
public class ManagerKit {

    public static final String LOGIN_USER = "sessionLoginUser";

    public static final String ORG_ID = "sessionOrgId";

    public static final String TOP_ORG_ID = "sessionTopOrgId";

    public static final String ROLE_TYPE = "sessionRoleType";

    public static final String ROLE_BEAN = "sessionRoleBean";

    public static Session getSession() {
        return ShiroKit.getSession();
    }

    public static CmuUser getUser() {
        return (CmuUser) getSession().getAttribute(LOGIN_USER);
    }

    public static String getUserId() {
        return (String) ShiroKit.getUser().getId();
    }

    public static String getCustomerId() {
        return ((CmuUser) ShiroKit.getPrincipal()).getId();
    }

    public static String getOrgId() {
        return (String) getSession().getAttribute(ORG_ID);
    }

    public static String getTopOrgId() {
        return (String) getSession().getAttribute(TOP_ORG_ID);
    }

    public static CmuRole getRole() {
        return (CmuRole) getSession().getAttribute(ROLE_BEAN);
    }

//    public static Set<Integer> getRoleType() {
//        return (Set<Integer>) getSession().getAttribute(ROLE_TYPE);
//    }
}
